import java.util.ArrayList;
import java.util.Scanner;

public class javazfx_2 {
    public static void main(String args[]) {
        ArrayList<Student> students = new ArrayList<>();
        Scanner reader = new Scanner(System.in);
        int snum, onum; // student numbers, operation numbers
        int i;
        snum = reader.nextInt();
        for (i = 0; i < snum; i++) {
            students.add(new Student(reader.next(), reader.next(), reader.nextInt()));
        }
        onum = reader.nextInt();
        for (i = 0; i < onum; i++) {
            String operation = reader.next();
            if (operation.equals("add")) {
                students.add(new Student(reader.next(), reader.next(), reader.nextInt()));
            } else if (operation.equals("delete")) {
                String kill = reader.next();
                for (i = 0; i < students.size(); i++) {
                    if (students.get(i).no.equals(kill)) {
                        students.remove(i);
                        break;
                    }
                }
            } else {
                String change = reader.next();
                int score = reader.nextInt();
                for (i = 0; i < students.size(); i++) {
                    if (students.get(i).no.equals(change)) {
                        Student newstu = new Student(students.get(i).no, students.get(i).name, score);
                        students.remove(i);
                        students.add(i, newstu);
                        break;
                    }
                }
            }
        }
        for(i=0; i<students.size(); i++){
            System.out.println(students.get(i));
        }
    }
}

class Student {
    String name;
    String no;
    int score;

    Student(String no, String name, int score) {
        this.name = name;
        this.no = no;
        this.score = score;
    }

    Student SetScore(int newscore) {
        this.score = newscore;
        return this;
    }

    public String toString() {
        return "no:" + no + " name:" + name + " score:" + Integer.toString(score);
    };
}